﻿using MediatR;
using RBAC.LuFang.API.Application.Command.EnterpriseCommand;
using RBAC.LuFang.Domain;
using RBAC.LuFang.Domain.Traceability;
using RBAC.LuFang.Domin.Services.TraceabilityService;

namespace RBAC.LuFang.API.Application.CommandHandlers.EnterpriseHandler
{
    //更新养殖场的企业信息
    public class EnterpriseUpdCommandHandler:IRequestHandler<EnterpriseUpdCommand,int>
    {
        private readonly IGoodsService _goodsService;

        public EnterpriseUpdCommandHandler(IGoodsService goodsService)
        {
            _goodsService = goodsService;
        }

        public async Task<int> Handle(EnterpriseUpdCommand request, CancellationToken cancellationToken)
        {
            var enterModel = new Enterprise() { enterpriseid =request.enterpriseid , livestockfarm =request.livestockfarm , personincharge =request.personincharge , number =request.number , enterprisename =request.enterprisename , provinceID =request.provinceID , theCityID =request.theCityID , countyID =request.countyID , enterpriseDate =request.enterpriseDate , enterpriseDesc =request.enterpriseDesc , enterpriseBan =request.enterpriseBan , enterprisePeople =request.enterprisePeople , goodsId =request.goodsId };
            return await _goodsService.AddEnterprise( enterModel );
        }
    }
}
